rm -rf zhcramfsTMP$1

gcc -static -m32 zserver.c -o zserver

cp -r initramfs/  zhcramfsTMP$1
#### cp -f zserver  zhcramfsTMP/x86-busybox/bin/

echo $1 | xargs -i sed -i 's/.*zhc$/ ifconfig eth0 192.168.8.{} netmask 255.255.255.0\n echo 1 > \/proc\/sys\/net\/ipv6\/conf\/eth0\/disable_ipv6 \n route add -net 192.168.2.0\/24 eth0 \n  route add -net 192.168.2.0\/24 gw 192.168.8.252 \n ifconfig \n nc -ll -p 4000 -e \/bin\/sh  \n  /g'  zhcramfsTMP$1/x86-busybox/init
##echo $1 | xargs -i sed -i 's/.*zhc$/ ifconfig eth0 192.168.8.{} netmask 255.255.255.0\n ifconfig \n /g'  zhcramfsTMP$1/x86-busybox/init

cd  zhcramfsTMP$1/x86-busybox
echo $1 | xargs -i bash -c "find . | cpio -o --format=newc  | gzip -9  > ../../../initramfs.busybox1.27.2.i386.cpio.genOnceVM{}.gz"

hexnum=$(echo $1 | sed '1i ibase=10;obase=16;' | bc | tr '[A-Z]' '[a-z]' )

cd ../../../

sudo qemu-system-i386 -m 50M  \
  -kernel linux-3.18.5/arch/x86/boot/bzImage -initrd initramfs.busybox1.27.2.i386.cpio.genOnceVM$1.gz  \
  -nographic -append "console=ttyS0" \
  -net nic,macaddr=00:aa:00:60:ff:${hexnum},vlan=0 -net socket,vlan=0,mcast=239.192.168.1:1102

## sudo qemu-system-i386 -m 50M  -net nic,macaddr=00:aa:00:60:00:01,model=ne2k_pci  -net tap,ifname=tap0  -kernel linux-3.18.5/arch/x86/boot/bzImage -initrd initramfs.busybox1.27.2.i386.cpio.genOnce{}.gz  -nographic -append "console=ttyS0" -net nic,macaddr=00:aa:00:60:00:02,vlan=1 -net socket,vlan=1,mcast=239.192.168.1:1102

